XPath 2.0 functions supported by Cordys |
Introduction
Cordys supports only specific set of XPath 2.0 functions. This page lists the supported functions and it's limitations.
Supported Functions
1. fn:min
Selects an item from the input sequence whose value is less than or equal to the value of every other item in the input sequence.
fn:min($arg as xs:anyAtomicType*) as xs:anyAtomicType?
Sample Code
Document document = new Document(); int xml = document.parseString("<weather>" + "<forecast day=\"1\" ><temperature>3.0</temperature> " + "</forecast> <forecast day=\"2\"> " + "<temperature>5.0</temperature></forecast>" + "<forecast day=\"3\"><temperature>4.0</temperature> " + "</forecast> </weather>"); XPath oXPath = XPath.getXPathInstance("min(/weather/forecast/temperature/text())"); System.out.println(oXPath.evaluateNumberResult(xml));
Output
3.0
2. fn:max
Selects an item from the input sequence whose value is greater than or equal to the value of every other item in the input sequence.
fn:max($arg as xs:anyAtomicType*) as xs:anyAtomicType?
Sample Code
Document document = new Document(); int xml = document.parseString("<weather>" + "<forecast day=\"1\" ><temperature>3.0</temperature> " + "</forecast> <forecast day=\"2\"> " + "<temperature>5.0</temperature></forecast>" + "<forecast day=\"3\"><temperature>4.0</temperature> " + "</forecast> </weather>"); XPath oXPath = XPath.getXPathInstance("max(/weather/forecast/temperature/text())"); System.out.println(oXPath.evaluateNumberResult(xml));
Output
5.0
3. fn:upper-case
Returns the value of $arg
after translating every character to its upper-case correspondent
fn:upper-case($arg as xs:string?) as xs:string
Sample Code
Document document = new Document(); int xml = document.parseString("<root><testdata attr='aTrI*7'>hA1@wE</testdata></root>"); XPath oXPath = XPath.getXPathInstance("upper-case(/root/testdata/text())"); System.out.println(oXPath.evaluateStringResult(xml));
Output
HA1@WE
Limitation
- This function is restricted to ASCII character set.
4. fn:lower-case
Returns the value of $arg
after translating every character to its lower-case correspondent
fn:lower-case($arg as xs:string?) as xs:string
Sample Code
Document document = new Document(); int xml = document.parseString("<root><testdata attr='aTrI*7'>hA1@wE</testdata></root>"); XPath oXPath = XPath.getXPathInstance("lower-case(/root/testdata/text())"); System.out.println(oXPath.evaluateStringResult(xml));
Output
ha1@we
Limitation
- This function is restricted to ASCII character set.